package com.flycms.module.activity.enums;

import lombok.Getter;

import java.util.Objects;

public enum ActivityTypeEnum {

    CONSULT(0,"咨询活动"),
    PLATFORM(1,"平台动态"),
    INDUSTRY(2,"行业观察"),
    NEWS(3,"工业新闻"),
    ACTIVITY(4,"活动信息"),
    POLICY(5,"政策聚焦");

    ActivityTypeEnum(Integer code,String desc){
        this.code = code;
        this.desc = desc;
    }

    @Getter
    Integer code;

    @Getter
    String desc;

    /**
     * 根据code值获取枚举描述
     * @param code 值
     * @return 对应描述
     */
    public static String getDescByCode(Integer code) {
        if(Objects.isNull(code)){
            return "";
        }
        ActivityTypeEnum[] values = values();
        for (ActivityTypeEnum anEnum : values) {
            if(code == anEnum.getCode()){
                return anEnum.getDesc();
            }
        }
        return "";
    }

}
